package test.com.sms.selenium.singlepoint.util;

import org.openqa.selenium.By;

import test.com.sms.selenium.framework.SeleniumPageUtil;
import test.com.sms.selenium.util.SeleniumUtil;

public class SpContractsQuoterNewQuoterPageUtil extends SeleniumPageUtil {
	public final static By CQN_HEAD = By.xpath("//*[@id='pnlPage']/table[1]/tbody/tr/td[1]"); 
	public final static By CQN_LINK_SAVE = By.id("Quoter_QuoteHdr1_btnSave");
	public final static By CQN_LINK_REFRESH = By.id("Quoter_QuoteHdr1_btnRefreshQuote");
	public final static By CQN_LINK_CLOSE = By.id("Quoter_QuoteHdr1_btnDone");
	public final static By CQN_SPAN_MSG = By.id("Quoter_QuoteHdr1_lblMsg");
	public final static By CQN_SPAN_TITLE = By.id("Quoter_QuoteHdr1_lblHdr");
	public final static By CQN_TD_QUOTE_TYPE = By.xpath("//*[@id='tblEdit']/tbody/tr[1]/td[1]");
	public final static By CQN_TD_DUE_DATE = By.xpath("//*[@id='tblEdit']/tbody/tr[1]/td[3]");
	public final static By CQN_LINK_DATE_CHANGE = By.id("Quoter_QuoteHdr1_btnDueDateRevise");
	public final static By CQN_TD_CUSTOMER = By.xpath("//*[@id='tblEdit']/tbody/tr[2]/td[1]");
	public final static By CQN_LINK_CUSTOMER_CHANGE = By.id("Quoter_QuoteHdr1_btnChangeCustomer");
	public final static By CQN_INPUT_CUSTOMER = By.id("Quoter_QuoteHdr1_txtCustomer");
	public final static By CQN_TD_CUSTID = By.xpath("//*[@id='tblEdit']/tbody/tr[2]/td[3]");
	public final static By CQN_INPUT_CUSTID = By.id("Quoter_QuoteHdr1_txtCustID");
	public final static By CQN_TD_PARTNER = By.xpath("//*[@id='tblEdit']/tbody/tr[2]/td[5]");
	public final static By CQN_CHECKBOX_PARTNER = By.id("Quoter_QuoteHdr1_chkPartner");
	public final static By CQN_TD_CONTRACT_ID = By.xpath("//*[@id='tblEdit']/tbody/tr[3]/td[1]");
	public final static By CQN_INPUT_CONTRACT_ID = By.id("Quoter_QuoteHdr1_txtContractID");
	public final static By CQN_TD_STATUS = By.xpath("//*[@id='tblEdit']/tbody/tr[3]/td[3]");
	public final static By CQN_TD_ROUND_RATES = By.xpath("//*[@id='tblEdit']/tbody/tr[3]/td[5]");
	public final static By CQN_CHEDKBOX_ROUND_RATES = By.id("Quoter_QuoteHdr1_chkRoundRates");
	public final static By CQN_TD_REVISION = By.xpath("//*[@id='tblEdit']/tbody/tr[4]/td[1]");
	public final static By CQN_INPUT_REVISION = By.id("Quoter_QuoteHdr1_txtQuoteRevision");
	public final static By CQN_INPUT__SUB_REV = By.id("Quoter_QuoteHdr1_txtSubRev");
	public final static By CQN_TD_REV_STATUS = By.xpath("//*[@id='tblEdit']/tbody/tr[4]/td[3]");
	public final static By CQN_TD_SING_OFF = By.xpath("//*[@id='tblEdit']/tbody/tr[4]/td[5]");
	public final static By CQN_TD_DESC  = By.xpath("//*[@id='tblEdit']/tbody/tr[5]/td[1]");
	public final static By CQN_INPUT_DESC = By.id("Quoter_QuoteHdr1_txtHdrDesc");
	public final static By CQN_TD_CUSTOMER_NO  = By.xpath("//*[@id='tblEdit']/tbody/tr[5]/td[3]");
	public final static By CQN_INPUT_CUSTOMER_NO = By.id("Quoter_QuoteHdr1_txtCustPONo");
	public final static By CQN_TD_SALE_PERSON  = By.xpath("//*[@id='tblEdit']/tbody/tr[6]/td[1]");
	public final static By CQN_SELECT_SALE_PERSON = By.id("Quoter_QuoteHdr1_cboSalesRepID");
	public final static By CQN_TD_BILL_FREQ  = By.xpath("//*[@id='tblEdit']/tbody/tr[6]/td[3]");
	public final static By CQN_SELECT_BILL_FREQ = By.id("Quoter_QuoteHdr1_cboBillingCycleID");
	public final static By CQN_TD_BILL_ADD  = By.xpath("//*[@id='tblEdit']/tbody/tr[7]/td[1]");
	public final static By CQN_SELECT_BILL_ADDR = By.id("Quoter_QuoteHdr1_cboBillToCustAddrGuid");
	public final static By CQN_TD_SHIP_ADD  = By.xpath("//*[@id='tblEdit']/tbody/tr[7]/td[3]");
	public final static By CQN_SELECT_SHIP_ADDR = By.id("Quoter_QuoteHdr1_cboShipToCustAddrGuid");
	public final static By CQN_TD_SHIP_ADD_OR  = By.xpath("//*[@id='tblEdit']/tbody/tr[7]/td[4]");
	public final static By CQN_CHECKBOX_SHIP_ADD_OR = By.id("Quoter_QuoteHdr1_chkShipToMultiFlag");

	// when input something into customer text, list displayed
	public final static By CQN_DIV_CUSTOMER_LIST = By.id("Quoter_QuoteHdr1_aceCustomer_completionListElem");
	public final static By CQN_TD_CUSTOMER_LIST_RECORD = By.xpath("//*[@id='Quoter_QuoteHdr1_aceCustomer_completionListElem']/table/tbody/tr/td['3M COMPANY']");
	
	/** elements of quoter just new*/
	public final static By CQN_TAB_REVISIONS = By.id("btnTab1");
	public final static By CQN_TAB_REVISIONS_INFO = By.id("btnTab2");
	public final static By CQN_TAB_ADDRESSES = By.id("btnTab3");
	public final static By CQN_TAB_LINE_DEFAULTS = By.id("btnTab4");
	public final static By CQN_TAB_QUOTER_LINES = By.id("btnTab5");
	public final static By CQN_TAB_UNIQUE_CONFIGS = By.id("btnTab6");
	public final static By CQN_TAB_DISCREPANCIES = By.id("btnTab7");
	public final static By CQN_TAB_ALL_PROBLEMS = By.id("btnTab8");
	public final static By CQN_TAB_USERS = By.id("btnTab9");
	public final static By CQN_TAB_QUOTE_DOCS = By.id("btnTab10");
	public final static By CQN_TAB_INVOICING = By.id("btnTab11");
	
	/** elements under Addresses tab*/
	public final static By CQN_LINK_NEW_ADDR_TAB = By.id("Quoter_AddressListAjax_btnAddressNew");
	public final static By CQN_LINK_UPDATE_FROM_MAS_ADDR_TAB = By.id("Quoter_AddressListAjax_btnUpdateFromMAS");
	public final static By CQN_LINK_MERGE_ADDR_TAB = By.id("Quoter_AddressListAjax_btnMerge");
	public final static By CQN_LINK_WHSE_CLOSEST_ADDR_TAB = By.id("Quoter_AddressListAjax_btnWhseClosest");
	public final static By CQN_LINK_IMPORT_ADDRESS_ADDR_TAB = By.id("Quoter_AddressListAjax_btnAddressImport");
	// check box under Addresses tab
	public final static By CQN_CHECKBOX_3M_ADDR_TAB = By.xpath("//*[@id='trbfbf1ef6-5aa8-439d-af3a-bb86a19d9b3a']/td[6]/input");
	public final static By CQN_CHECKBOX_BILL_A2711_ADDR_TAB = By.xpath("//*[@id='tr2b73f317-98ad-40ef-b905-f9d50a357bdd']/td[6]/input");
	public final static By CQN_CHECKBOX_MAPLEWOOD_MN_ADDR_TAB = By.xpath("//*[@id='tr0a8fc516-9f39-4aba-8c76-458ef6023a7c']/td[6]/input");
	
	/** elements under Line Defaults tab*/
	public final static By CQN_LINK_SAVE_LINE_TAB = By.id("Quoter_QuoteDefaultsAjax_btnSaveAjax");
	public final static By CQN_LINK_REFRESH_LINE_TAB = By.id("Quoter_QuoteDefaultsAjax_btnRefresh");
	public final static By CQN_SELECT_SHIP_TO_ADDR_LINE_TAB = By.id("Quoter_QuoteDefaultsAjax_cboShipToCustAddrGuid");
	
	/** elements under Quoter Lines tab*/
	public final static By CQN_LINK_EXPORT_FOR_CUST_QL_TAB = By.id("Quoter_QuoteLinesAjax_btnExportForCust");
	public final static By CQN_LINK_EXPORT_QL_TAB = By.id("Quoter_QuoteLinesAjax_btnExport");
	public final static By CQN_LINK_QUICK_EXPORT_QL_TAB = By.id("Quoter_QuoteLinesAjax_lnkExportToExcel");
	public final static By CQN_LINK_IMPORT_QL_TAB = By.id("Quoter_QuoteLinesAjax_btnImport");
	public final static By CQN_LINK_REORDER_LINES_QL_TAB = By.id("Quoter_QuoteLinesAjax_btnReorderContLines");
	public final static By CQN_LINK_REFRESH_QL_TAB = By.id("Quoter_QuoteLinesAjax_btnRefresh");
	public final static By CQN_LINK_ADD_ITEMS_QL_TAB = By.id("Quoter_QuoteLinesAjax_btnAddItemsExcel");
	public final static By CQN_LINK_ADD_DELL_SERIAL_QL_TAB = By.id("Quoter_QuoteLinesAjax_btnAddItemExcelDell");
	public final static By CQN_BUTTON_OPEN_ITEM_QL_TAB = By.id("Quoter_QuoteLinesAjax_btnAddItems");
	public final static By CQN_LINK_MAS_RATE_0_QL_TAB = By.id("tdEditMASRate0");
	public final static By CQN_LINK_MAS_RATE_1_QL_TAB = By.id("tdEditMASRate1");
	public final static By CQN_LINK_DISCOUNT_PCT_0_QL_TAB = By.id("tdEditDiscountPct0");
	public final static By CQN_LINK_DISCOUNT_PCT_1_QL_TAB = By.id("tdEditDiscountPct1");
	public final static By CQN_LINK_DISCOUNT_DESC_QL_TAB = By.id("tdEditDiscountDesc0");
	
	public static void enterNewQuoterPage(){
		SpContractsQuoterPageUtil.enter();
		SpContractsQuoterPageUtil.displayHidenMenus(new By[]{SpContractsQuoterPageUtil.STQ_LINK_QUOTER});
		SeleniumUtil.waitOnElements(new By[]{SpContractsQuoterPageUtil.STQ_LINK_QUOTER_NEW});
		SeleniumUtil.click(SeleniumUtil.getCachedElement(SpContractsQuoterPageUtil.STQ_LINK_QUOTER_NEW));
		SeleniumUtil.waitForFixedMilliseconds(1000);
		waitForNewQuoterDefaultPageToLoad();
	}
	private static void waitForNewQuoterDefaultPageToLoad() {
		SeleniumUtil.selectDefaultContent();
		SeleniumUtil.selectFrame(SpHomePageUtil.HOME_FRAME_CONTENT_NAME);
		SeleniumUtil.waitOnElements(new By[]{
				CQN_LINK_SAVE,CQN_LINK_REFRESH,CQN_LINK_CLOSE,CQN_SELECT_SHIP_ADDR
		});
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_LINK_SAVE));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_LINK_REFRESH));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_LINK_CLOSE));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_SELECT_SHIP_ADDR));
	}
	public static void waitForPageToLoadAfterNewQuoter() {
		SeleniumUtil.waitOnElements(new By[]{
				CQN_TAB_REVISIONS,CQN_TAB_REVISIONS_INFO,CQN_TAB_ADDRESSES,CQN_TAB_LINE_DEFAULTS,
				CQN_TAB_QUOTER_LINES, CQN_TAB_UNIQUE_CONFIGS, CQN_TAB_DISCREPANCIES, CQN_TAB_ALL_PROBLEMS,
				CQN_TAB_USERS, CQN_TAB_QUOTE_DOCS, CQN_TAB_INVOICING
		});
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_TAB_REVISIONS));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_TAB_REVISIONS_INFO));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_TAB_ADDRESSES));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_TAB_QUOTER_LINES));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_TAB_UNIQUE_CONFIGS));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_TAB_DISCREPANCIES));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_TAB_ALL_PROBLEMS));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_TAB_USERS));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_TAB_QUOTE_DOCS));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_TAB_INVOICING));
	}
	public static void waitForQuoterLinesTabToLoad() {
		SeleniumUtil.waitOnElements(new By[]{
				CQN_LINK_EXPORT_FOR_CUST_QL_TAB, CQN_LINK_EXPORT_QL_TAB, CQN_LINK_QUICK_EXPORT_QL_TAB, CQN_LINK_IMPORT_QL_TAB,
				CQN_LINK_REORDER_LINES_QL_TAB, CQN_LINK_REFRESH_QL_TAB, CQN_LINK_ADD_ITEMS_QL_TAB, CQN_LINK_ADD_DELL_SERIAL_QL_TAB, 
				CQN_BUTTON_OPEN_ITEM_QL_TAB
		});
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_LINK_EXPORT_FOR_CUST_QL_TAB));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_LINK_EXPORT_QL_TAB));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_LINK_QUICK_EXPORT_QL_TAB));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_LINK_IMPORT_QL_TAB));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_LINK_REORDER_LINES_QL_TAB));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_LINK_REFRESH_QL_TAB));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_LINK_ADD_ITEMS_QL_TAB));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_LINK_ADD_DELL_SERIAL_QL_TAB));
		SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(CQN_BUTTON_OPEN_ITEM_QL_TAB));
	}
}
